package com.springcolud.alibaba.hystrix.service;


import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;

/**
 * @Author:RenPu
 * @Date: 2020/6/30 18:01
 * @Version: 1.0
 * @description:
 */

@Service
public class HystrixPaymentService {


    /**
     * 此方法肯定成功
     * @param id
     * @return
     */
    public String test_OK(Long id){
        return  "线程池："+ Thread.currentThread().getName()+"*********"+id+"操作成功O(∩_∩)O哈哈~";

    }


    /**
     * 模拟异常发生，让服务降级
     *
     * @param id
     * @return
     */
    public String test_ERROR(Long id){

        int timeOut=3;
        try {
            TimeUnit.SECONDS.sleep(timeOut);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }


        return "线程池："+ Thread.currentThread().getName()+ id +"操作延时了o(╥﹏╥)o";

    }
}
